
*Replication File for "Public Perceptions of Local Influence"

*The following files are used in this replication archive.
*1.) Code file (This file)
*2.) CCES20_TUF_OUTPUTanalysisvars. This is the Tufts module of the 2020 Cooperative Election Study. Survey questions are here. Only relevant vars included.
*3.) CCES21_TUF_OUTPUTanalysisvars. This is the Tufts module of the 2021 Cooperative Election Study. Survey questions are here too. Only relevant vars includes.
*4.) Handcodes20. This is a file that categorizes the local influentials mentioned by respondents in the 2020 survey into groupings listed in Table 3.
*5.) Personal_handcodes. This is the file that categorizes the local influentials mentioned by respondents in the 2021 survey (Personal condition) into groupings listed in Table 3. 
*6.) Power_handcodes. This is the file that categorizes the local influentials mentioned by respondents in the 2021 survey (Power condition) into groupings listed in Table 3. 
*7.) valid_vars2020. In part of the analysis for Table 2, we bring in the vote validation records (available in the 2020 CES common content file) to measure voting patterns among our respondents.
*8.) paper_tabs. This file does two things. In one tab, it contains the means and CIs for production of Figure 1. In two other tabs, it shows the categories of influentials of each of the influentials named in the power and personal conditions. Recall that in these conditions, respondents could name up to three influentials. Code below then produces the overall summary of categories for these conditions used in Table 3. 




*2020 analysis

u CCES20_TUF_OUTPUT, clear
merge 1:1 caseid using handcodes20


gen weight = teamweight

gen know_someone = 1  if TUF341_DK ==2
replace know_someone = 0 if TUF341_DK == 1
replace know_someone = 0 if junk == 1

ci mean know_someone [aw=weight]
*copied for Fig 1 below

*Attn chcks
bysort comptype: tab know [aw=weight]
gen surveytime =endtime-starttime
reg know_someone surveytime [aw=weight]

	
*Demographics (Table 1)
gen age = 2020-birthyr
gen age1839 = 1 if age <=39
gen age4059 = 1 if age >=40 & age <=59
gen age60p = 1 if age >=60 & age != .
recode age1839 age40 age60 (.=0)

sum know if age18 == 1 [aw=weight]
sum know if age40 == 1 [aw=weight]
sum know if age60 == 1 [aw=weight]

reg know age40 if age60 == 0 [aw=weight]
reg know age60 if age40 == 0 [aw=weight]



gen female = 1 if gender ==2 
replace female = 0 if gender == 1

sum know if female ==1 [aw=weight]
sum know if female ==0 [aw=weight]

reg know female [aw=weight]


gen married = marstat
recode married 1 6 = 1 2 3 4 5 = 0

sum know if married ==1 [aw=weight]
sum know if married ==0 [aw=weight]

reg know married [aw=weight]


gen white = race  == 1
gen black = race == 2
gen hisp = race == 3
gen otherrace = 1 if white == 0 & black== 0 & hisp ==0 
recode otherra .=0

sum know if white ==1 [aw=weight]
sum know if black ==1 [aw=weight]
sum know if hisp ==1 [aw=weight]
sum know if other ==1 [aw=weight]

reg know black if white ==1 | black == 1 [aw=weight]
reg know hisp if white ==1 | hisp == 1  [aw=weight]
reg know other if white ==1 | other == 1 [aw=weight]


gen college = educ
recode college 5 6  = 1 1 2 3 4 =0

sum know if college ==1 [aw=weight]
sum know if college ==0 [aw=weight]

reg know college [aw=weight]


gen church = pew_chur
recode church  1 2  = 1 3 4 5 6 = 0 7 =. 


sum know if church ==1 [aw=weight]
sum know if church ==0 [aw=weight]

reg know church [aw=weight]


gen dem = pid3 == 1
gen rep = pid3 == 2
gen ind = 1 if dem == 0 & rep ==0 
recode ind .=0

sum know if dem ==1 [aw=weight]
sum know if rep ==1 [aw=weight]
sum know if ind ==1 [aw=weight]

reg know rep if rep == 1 | dem ==1 [aw=weight]
reg know ind if rep == 1 | ind == 1 [aw=weight]


gen resident5yr = 1 if CC20_361 == 6 
replace resident5 = 0 if CC20_361 <6


sum know if resident ==1 [aw=weight]
sum know if resident ==0 [aw=weight]

reg know resident [aw=weight]

gen homeowner = 1 if ownhome == 1
recode home .=0 if ownhome !=. 

sum know if homeow ==1 [aw=weight]
sum know if homeow ==0 [aw=weight]

reg know homeown [aw=weight]


gen city = urbancity == 1
gen suburbu = urbancity == 2
gen town = urbancity == 3
gen rural = urbancity == 4

sum know if city ==1 [aw=weight]
sum know if suburb ==1 [aw=weight]
sum know if town ==1 [aw=weight]
sum know if rural ==1 [aw=weight]

reg know suburb if suburb ==1 | city == 1 [aw=weight]
reg know town if town ==1 | city == 1 [aw=weight]
reg know rural if rural ==1 | city == 1 [aw=weight]


gen inc_040 = 1 if faminc <=4
gen inc_4080 = 1 if famin >4 & faminc <= 8
gen inc_80p = 1 if faminc >8 & faminc <=16
gen inc_nosay = 1 if faminc == 97
recode inc_040-inc_nosay (.=0) if faminc != . 

sum know if inc_040 ==1 [aw=weight]
sum know if inc_408 ==1 [aw=weight]
sum know if inc_80p ==1 [aw=weight]
sum know if inc_nosa ==1 [aw=weight]

reg know inc_40 if inc_04 ==1 | inc_40 == 1 [aw=weight]
reg know inc_80 if inc_80 == 1 | inc_04 == 1 [aw=weight]
reg know inc_no if inc_no ==1 | inc_04 ==1 [aw=weight]

*Civic/Political Correlates (Table 2)

merge 1:1 caseid using valid_vars2020, gen(vv) keep(match master)
gen valid2020vote = 1 if cl_2020gvm != "NA"
replace valid2020vote = 0 if cl_2020gvm == "NA"


tab valid if know == 1 [aw=weight]
tab valid if know == 0 [aw=weight]
bysort know: sum valid [aw=weight]
ttesti 783    .5866997   .4927446 217   .6999969   .4592717


tab newsint if know == 1 [aw=weight]
tab newsint if know == 0 [aw=weight] 
gen newsmost = newsint
recode newsmost 1=1 nonmis =0
bysort know: sum newsmost [aw=weight]
ttesti 779  .4666374     .49921  217  .6364109   .4820954



recode CC20_300_1-CC20_300_4 (2=0)
egen  media24hours = rowtotal(CC20_300_1-CC20_300_4 )
ci mean media24hours if know == 0 [aw=weight]
ci mean media24hours if know == 1 [aw=weight]
bysort know: sum media24 [aw=weight]
ttesti 783 1.860408   .9541054  217  2.271685   .9930156


recode   CC20_300d_1-CC20_300d_6 (2=0)
egen socialmedia = rowtotal(CC20_300d_1-CC20_300d_6)
ci mean socialme if know == 0 [aw=weight]
ci mean socialme if know == 1 [aw=weight]
bysort know: sum socialme [aw=weight]
ttesti 783  1.268367   1.269631  217   1.879052   1.631475


recode TUF370 (2=0) (3=0)
*Trust
ci mean TUF370 if know == 0 [aw=weight]
ci mean TUF370 if know == 1 [aw=weight]
bysort know: sum TUF370 [aw=weight]
ttesti 781 .1737677   .3791559  217 .2512988   .4347185


recode CC20_430a_1-CC20_430a_6 (2=0)
egen count_activism = rowtotal(CC20_430a_1-CC20_430a_6)

bysort know:sum count_activism [aw=weight]
ttesti   783 .667757   1.158071  217  1.288748   1.563948


*Table 3
tab type [aw=weight]


**2021 analysis
u CCES21_TUF_OUTPUT, clear
merge 1:1 caseid using personal_handcodes, nogen
merge 1:1 caseid using power_handcodes, nogen

gen treatment_personal = treat_group500 == 1

gen weight = teamweight


gen personal_know = 1 if CES501_dk == 0 & treatment_p == 1
replace personal_know = 0 if CES501_dk == 1 & treatment_p ==1
replace personal_know = 0 if ces501_junk == 1

gen power_know =1 if CES502_dk == 0 & treatment ==0 
replace power_know = 0 if CES502_dk == 1 & treatment == 0
replace power_know =0 if ces502_junk == 1


ci mean personal power [aw=weight]
*copied for Fig 1 below

*Demographics (Table 1)

gen age = 2021-birthyr
gen age1839 = 1 if age <=39
gen age4059 = 1 if age >=40 & age <=59
gen age60p = 1 if age >=60 & age != .
recode age1839 age40 age60 (.=0)

sum personal power if age18 == 1 [aw=weight]
sum personal power if age40 == 1 [aw=weight]
sum personal power if age60 == 1 [aw=weight]

reg personal age40 if age60 == 0 [aw=weight]
reg personal age60 if age40 == 0 [aw=weight]
reg power age40 if age60 == 0 [aw=weight]
reg power age60 if age40 == 0 [aw=weight]


gen female = 1 if gender4 ==2 
replace female = 0 if gender4 == 1

sum personal power if female ==1 [aw=weight]
sum personal power if female ==0 [aw=weight]

reg personal female [aw=weight]
reg power female [aw=weight]

gen married = marstat
recode married 1 6 = 1 2 3 4 5 = 0

sum personal power if married == 1 [aw=weight]
sum personal power if married == 0 [aw=weight]

reg personal married [aw=weight]
reg power married [aw=weight]

gen white = race  == 1
gen black = race == 2
gen hisp = race == 3
gen otherrace = 1 if white == 0 & black== 0 & hisp ==0 
recode otherra .=0

sum personal power if white == 1 [aw=weight]
sum personal power if black == 1 [aw=weight]
sum personal power if hisp == 1 [aw=weight]
sum personal power if otherra == 1 [aw=weight]

reg personal black if black == 1 | white ==1  [aw=weight]
reg personal hisp if hisp == 1 | white == 1 [aw=weight]
reg personal other if other ==1 | white == 1 [aw=weight]

reg power black if black == 1 | white ==1  [aw=weight]
reg power hisp if hisp == 1 | white == 1 [aw=weight]
reg power other if other ==1 | white == 1 [aw=weight]

gen college = educ
recode college 5 6  = 1 1 2 3 4 =0

sum personal power if college == 1 [aw=weight]
sum personal power if college == 0 [aw=weight]

reg personal college [aw=weight]
reg power college [aw=weight]

gen church = pew_chur
recode church  1 2  = 1 3 4 5 6 = 0 7 =. 

sum personal power if church == 1 [aw=weight]
sum personal power if church == 0 [aw=weight]

reg personal church [aw=weight]
reg power church [aw=weight]


gen dem = pid3 == 1
gen rep = pid3 == 2
gen ind = 1 if dem == 0 & rep ==0 
recode ind .=0

sum personal power if dem == 1 [aw=weight]
sum personal power if rep ==1 [aw=weight]
sum personal power if ind == 1 [aw=weight]

reg personal dem if dem ==1 | rep == 1 [aw=weight]
reg personal ind if ind ==1 | rep == 1 [aw=weight]
reg power dem if dem ==1 | rep == 1 [aw=weight]
reg power ind if ind ==1 | rep == 1 [aw=weight]


gen resident5yr = 1 if CC21_361x == 6 
replace resident5 = 0 if CC21_361x <6

sum personal power if resident ==1 [aw=weight]
sum personal power if resident == 0 [aw=weight]

reg personal resident [aw=weight]
reg power resident [aw=weight]

gen homeowner = 1 if ownhome == 1
recode home .=0 if ownhome !=. 

sum personal power if homeown ==1 [aw=weight]
sum personal power if homeown == 0 [aw=weight]

reg personal homeown [aw=weight]
reg power homeown [aw=weight]

gen city = urbancity == 1
gen suburbu = urbancity == 2
gen town = urbancity == 3
gen rural = urbancity == 4

sum personal power if city == 1 [aw=weight]
sum personal power if suburb == 1 [aw=weight]
sum personal power if town == 1 [aw=weight]
sum personal power if rural == 1 [aw=weight]

reg personal suburb if suburb ==1 | city == 1 [aw=weight]
reg personal town if town ==1 | city == 1 [aw=weight]
reg personal rural if rural ==1 | city ==1 [aw=weight]

reg power suburb if suburb ==1 | city == 1 [aw=weight]
reg power town if town ==1 | city == 1 [aw=weight]
reg power rural if rural ==1 | city ==1 [aw=weight]



gen inc_040 = 1 if faminc <=4
gen inc_4080 = 1 if famin >4 & faminc <= 8
gen inc_80p = 1 if faminc >8 & faminc <=16
gen inc_nosay = 1 if faminc == 97
recode inc_040-inc_nosay (.=0) if faminc != . 

sum personal power if inc_04 == 1 [aw=weight]
sum personal power if inc_40 == 1 [aw=weight]
sum personal power if inc_80 == 1 [aw=weight]
sum personal power if inc_no == 1 [aw=weight]

reg personal inc_40 if inc_40 == 1 | inc_0 == 1 [aw=weight]
reg personal inc_80 if inc_0 == 1 | inc_80 == 1 [aw=weight]
reg personal inc_no if inc_0 == 1 | inc_no == 1 [aw=weight]

reg power inc_40 if inc_40 == 1 | inc_0 == 1 [aw=weight]
reg power inc_80 if inc_0 == 1 | inc_80 == 1 [aw=weight]
reg power inc_no if inc_0 == 1 | inc_no == 1 [aw=weight]


*Table 3 
tab cat1 [aw=weight]
tab cat2 [aw=weight]
tab cat3 [aw=weight]

tab cat1_power [aw=weight]
tab cat2_power [aw=weight]
tab cat3_power [aw=weight]
*These are copied into paper_tabs.xslx so that categories for each influential mentioned (up to 3) can be summed). 


import excel paper_tabs.xlsx, sheet(personal) clear first
egen n = total(weighted)
gen pct = weighted/n
collapse (sum) pct, by(cat)


import excel paper_tabs.xlsx, sheet(power) clear first
egen n = total(weighted)
gen pct = weighted/n
collapse (sum) pct, by(cat)

*Figure 1
import excel paper_tabs.xlsx, sheet(fig1) clear first
replace m = m*100
replace lb = lb*100 
replace ub = ub*100

twoway (scatter m c, mc(black)) (rspike lb ub c, lc(gs8)), ///
scheme(s1mono) plotregion(style(none)) xscale(noextend) yscale(noextend) ///
ylabel(0(10)50) xlabel(1 "Community" 2 "Personal" 3 "Power", valuelabels angle(forty_five)) legend(off) ytitle(Percent Identfying an Influential Person) xsize(4) ysize(6) xtitle(Question-Wording Variation)
graph export fig1.png, replace
graph export fig1.tif, replace

